﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing.Design;
using System.Windows.Forms.Design;
using System.Windows.Forms;
using System.Reflection;

namespace ProgNetExtensions.Editors
{
    public class DataProviderNameEditor : UITypeEditor
    {
        public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
        {
            return UITypeEditorEditStyle.DropDown;
        }
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService srv = (IWindowsFormsEditorService)context.GetService(typeof(IWindowsFormsEditorService));
            ListBox cb = new ListBox();
            cb.Items.Add("AasdasdA");

            Type t = typeof(HomeHelper.DataSources.ProviderNames);
            FieldInfo[] fis = t.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
            
            foreach (FieldInfo fi in fis)
            {
                cb.Items.Add(fi.Name);
            }

            srv.DropDownControl(cb);
            return base.EditValue(context, provider, value);
        }
    }
}
